<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var obj ={
            id:1,
            pname:'小米',
            price:1999,
            num:2000
        };     //定义属性
        //修改值
        Object.defineProperty(obj,'num',{
            value:1000
        });
        //添加值
        Object.defineProperty(obj,'sex',{
            value:'男',
            enumerable:true//默认false就是不能遍历的
        })
        //不允许重写
        Object.defineProperty(obj,'id',{
            // value:2,
            writable:false,
        })
        obj.id = 2;
        //目标属性是否可以遍历
        Object.defineProperty(obj,'address',{
            value : '湖南省',
            enumerable:true,
            writable:false,
            configurable:false//不允许被删除
            // configurable:true允许被删除
        })
        delete obj.address;
        console.log(obj);
        console.log(Object.keys(obj));
    </script>
</body>
</html>